using Godot;
using System;

public class Game : Node2D
{
    // GDScript    preload("").instance();

    private PackedScene emeryCls;

    private Path2D _myPath;

    // Called when the node enters the scene tree for the first time.
    public override void _Ready()
    {
        GD.Print("Hello World by xhzhang");

        Button addButton = GetNode<Button>("HUD/AddButton");
        if (addButton != null)
        {
            addButton.Connect("pressed", this, "OnAddClick");
        }

        emeryCls = GD.Load<PackedScene>("res://Actors/Emery.tscn");

        _myPath = GetNode<Path2D>("Path2D");
    }

    public void OnAddClick()
    {
        Emery em = emeryCls.Instance() as Emery;
        GD.Randomize();
        em.Speed = (int)GD.RandRange(1, 100);
        _myPath.AddChild(em);
    }
}
